home *** CD-ROM | disk | FTP | other *** search
- Path: howland.reston.ans.net!usc!usc!not-for-mail
- From: wawda@alcor.usc.edu (Abu Wawda)
- Newsgroups: comp.lang.c
- Subject: Got Questions About Multi-Dimension Arrays (After Reading FAQ)
- Date: 31 Jan 1996 18:23:39 -0800
- Organization: University of Southern California, Los Angeles, CA
- Sender: wawda@alcor.usc.edu
- Distribution: world
- Message-ID: <4ep87b$o60@alcor.usc.edu>
- NNTP-Posting-Host: alcor.usc.edu
-
- I read questions 6.19 and 6.20 from the FAQ that deal with
- multi-dimensional arrays but am still confused. If someone can clear
- up my confusion, I would really appreciate it. Bascailly I still don't
- see why it isn't possible to do this:
-
- void myfunc(int *array,int rows,int cols)
- {
- printf("%d\n",array[1][1]);
- }
-
- and call the function like this:
-
- int m[2][2] = {1, 2, 3, 4};
-
- myfunc(m,2,2);
-
- If I understand correctly, a multideminsional array is really stored
- continguously like this in memory:
-
- array[0][0] | 1 | memory address a
- array[0][1] | 2 | memory address a+sizeof(int)
- array[1][0] | 3 | ....
- array[1][1] | 4 | ....
-
- So why can't C convert from pointer to integer to a multidemsional
- array. The reason I want to do this is because my function needs to
- take in an array of any width and height. Thank you for your time,
-
- Abu Wawda
- wawda@scf.usc.edu
-